let brain = require("brain.js");
let json = require("./model.json");
let data = require("../res/res.json");

let network = new brain.NeuralNetwork();
network.fromJSON(json);

// for (let item in data) {
//   let o = item - 0 + 1;
//   let i = item - 0 - 1;
//   if (data[o] && item >= 2024140) {
//     // if (data[o] && item >= 2024110) {
//     let blue = data[item].blue[0];
//     let iblue = data[i].blue[0];
//     let wzj = data[item].wzjblue;
//     if (blue > iblue) {
//       wzj.push(1);
//     } else {
//       wzj.push(0);
//     }
//     const output = network.run(wzj);
//     console.log(
//       item + "预测蓝球结果--->",
//       output.map((x) => Math.round(x * 16)),
//       "真实结果--->",
//       data[o].blue
//     );
//   }
// }
function blueyc(n = 2) {
  let keys = Object.keys(data);
  let o = keys[keys.length - n];
  let i = keys[keys.length - n - 1];
  let blue = data[o].blue[0];
  let iblue = data[i].blue[0];
  let wzj = data[o].wzjblue;
  // if (blue > iblue) {
  //   wzj.push(1);
  // } else {
  //   wzj.push(0);
  // }
  // console.log(o, i);

  const output = network.run(wzj);
  let res = [Math.round(output[0] * 100)];
  console.log(o - 0 + 1, "蓝球结果--->", res);
  return res;
}
blueyc();
module.exports = blueyc;
